package cn.nupt.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import cn.nupt.model.MemberRecord;
import cn.nupt.util.DBTool;

public class MemberRecordDAOImpl implements MemberRecordDAO{

	@Override
	//插入一条用户绑定会员卡的记录
	public int insertRecord(MemberRecord memberRecord) {
		int row = 0;//受影响的行数
		Connection conn = null;
		PreparedStatement prst = null;
		String sql = "insert into memberrecord (member_id,card_id,card_type) values(?,?,?)";
		conn = DBTool.getConnection();
		try{
			prst = conn.prepareStatement(sql);
			prst.setInt(1, memberRecord.getMemberId());
			prst.setInt(2, memberRecord.getCardId());
			prst.setInt(3, memberRecord.getCardType());
			row = prst.executeUpdate();
		}catch(SQLException ex ){
			ex.printStackTrace();
		}finally{
			DBTool.close(prst, conn);	//	注意关闭数据库相关连接
		}
		
		return row;
	}

}
